package main

import (
	"Dataform"
	"Logger"
	"encoding/json"
	"net"
	"os"
)

var serverList Dataform.ServerInfos

func setLogger() {
	Logger.SetConsole(true)
	Logger.SetRollingDaily("../logs", "Gate-logs.txt")
}

func readConfigFile() {
	serverConfig, err := os.Open("serverconfigs.conf")
	checkError(err)
	defer serverConfig.Close()
	buffer := make([]byte, 2048)
	length, err := serverConfig.Read(buffer)
	checkError(err)
	err = json.Unmarshal(buffer[:length], &serverList)
	checkError(err)
	Logger.Debug(serverList)
}

func setClientListener() {
	listener, err := net.Listen("tcp")
}

func main() {
	setLogger()
	readConfigFile()

}

func checkError(err error) {
	if err != nil {
		Logger.Error(err.Error())
		os.Exit(1)
	}
}
